package com.sibu.yx.promotion.common.util;

import com.doubo.common.enums.AppName;
import com.doubo.common.generate.IdCodeGenerator;
import com.doubo.common.generate.ObjectId;
import com.doubo.common.util.DateUtil;
import com.doubo.common.util.StringUtil;
import com.sibu.yx.promotion.common.enums.IdCodeTypeEnum;
import lombok.extern.slf4j.Slf4j;

/**
 * 序列生成器
 */
@Slf4j
public class SeqGenUtil {

    /**
     * 订单号生成器
     */
    private final static IdCodeGenerator ORDER_CODE_GENERATOR = new IdCodeGenerator(IdCodeTypeEnum.ORDER_CODE.getCode());

    /**
     * 反馈号生成器
     */
    private final static IdCodeGenerator FEED_BACK_CODE_GENERATOR = new IdCodeGenerator(IdCodeTypeEnum.FEED_BACK_CODE.getCode());


    /**
     * 结算单号
     */
    private final static IdCodeGenerator SETTLE_ORDER_CODE_GENERATOR = new IdCodeGenerator(IdCodeTypeEnum.SETTLE_ORDER_CODE.getCode());



    private final static IdCodeGenerator SETTLE_PROCESSED_CODE_GENERATOR = new IdCodeGenerator(IdCodeTypeEnum.SETTLE_PROCESS_ORDER_CODE.getCode());


    /**
     * 流水号（订单号、退款、退货流水号等）
     *
     * @return
     */
    public static String getOrderCode() {
        return ORDER_CODE_GENERATOR.nextId();
    }


    /**
     * 描述：反馈号
     * 2016年9月30日
     */
    public static String getFeedBackCode() {
        return FEED_BACK_CODE_GENERATOR.nextId();
    }


    /*
     * @description: 生成结算打款流水号
     * @param: []
     * @return: java.lang.String
     **/
    public static String getSettleProcessedCode(){
        return SETTLE_PROCESSED_CODE_GENERATOR.nextId();
    }



    public static String getSettleOrderCode(){
        return SETTLE_ORDER_CODE_GENERATOR.nextId();
    }


    /**
     * 判断输入的字符串是否是UUID(包含32位和36位的验证)
     *
     * @param uuid
     * @return
     */
    public static boolean isUUID(String uuid) {
        return StringUtil.isUUID(uuid);
    }

    /**
     * 判断输入的字符串是否是UUID(包含32位和36位的验证)
     *
     * @param uuid
     * @return
     */
    public static boolean isNotUUID(String uuid) {
        return StringUtil.isNotUUID(uuid);
    }


    public static String getId() {
        return ObjectId.get(AppName.DOUBO_MQ).toHexString();
    }

    public static String genReqSeq() {
        return DateUtil.getNowTimeYYYYMMddHHMMSS() + DateUtil.getNowTimeYYYYMMddHHMMSS();
    }

    public static void main(String[] args) {
        // String guid = UUID.randomUUID().toString().replace("-", "");
        //log.info(guid);
        log.info(getOrderCode());
    }
}
